import 'package:demo/theme/app_colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:get/get.dart';

import '../../../theme/app_text_theme.dart';
import 'apply_controller.dart';

class ApplyView extends GetView<ApplyController> {
  const ApplyView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color_bg,
      appBar: AppBar(
        title: Text('额度申请',style: text_title_black)
      ),
      body: SingleChildScrollView(child: Column(children: [
        Container(
          color: const Color(0xFFE9F7FE),
          padding: EdgeInsets.symmetric(horizontal: 15.w,vertical: 9.w),
          width: Get.width,
          child: Text('完成以下认证即可马上领钱' ,style: text_main_12)),
        SizedBox(height: 15.w),
        Container(
          margin: EdgeInsets.symmetric(horizontal: 15.w),
          width: Get.width,
          decoration: BoxDecoration(
              color: Color_white,
              borderRadius: BorderRadius.all(Radius.circular(8.w))
          ),
          child: Column(
            crossAxisAlignment : CrossAxisAlignment.start,
            children: [
              SizedBox(height: 30.w),
              Container(
                width: Get.width - 30.w - 40.w,
                margin: EdgeInsets.symmetric(horizontal: 20.w),
                child: KeyboardListener(
                  focusNode: controller.focusNode,
                  child: TextField(
                    autofocus: true,
                    inputFormatters:[FilteringTextInputFormatter.digitsOnly],
                    maxLength: 20,
                    onChanged: (value) => controller.moneyStr = value,
                    cursorColor: Color_main,
                    style: text_main_30,
                    keyboardType: TextInputType.number,
                    decoration: InputDecoration(
                      prefixIcon: Container(alignment:Alignment.bottomLeft ,width : 15.w,child: Text('¥', style: text_main_20)),
                      prefixIconConstraints: BoxConstraints(maxHeight: 40.w, minWidth: 15.w),
                      isDense: true,
                      contentPadding: EdgeInsets.symmetric(vertical: 3.w,horizontal: 6.w),
                      counterText: "", // 去掉底部计数
                      enabledBorder:  const UnderlineInputBorder(borderSide: BorderSide(color: Color_main,width: 0.5)), //无焦点时状态
                      focusedBorder:  const UnderlineInputBorder(borderSide: BorderSide(color: Color_main,width: 0.5)), //有焦点时状态
                      hintText: '最高可借200,000',
                      hintStyle: text_main_30,
                    ),
                  ),
                ),
              ),

              SizedBox(height: 15.w),
              Text('单笔可借1000-20万元，请输入1000的整数倍' ,style: text_grey_12).marginOnly(left: 20.w),
              SizedBox(height: 25.w),
              Container(
                height: 40.w,
                margin: EdgeInsets.symmetric(horizontal: 20.w),
                child: InkWell(
                  onTap: () => controller.chooseTime(),
                  child: Row(children: [
                    Expanded(child: Text('借款期限' ,style: text_131732_14)),
                    SizedBox(width: 6.w),
                    Obx(()=> Text(controller.selectTime.value.value ,style: text_131732_14)),
                    SizedBox(width: 3.w),
                    Image.asset('assets/images/ic_next.png',width: 15.w,height: 15.w)
                  ]),
                ),
              ),
              Container(margin: EdgeInsets.symmetric(horizontal: 20.w), height: 0.2,color: Color_line),
              Container(
                height: 40.w,
                margin: EdgeInsets.symmetric(horizontal: 20.w),
                child: InkWell(
                  onTap: () => controller.chooseUse(),
                  child: Row(children: [
                    Expanded(child: Text('借款用途' ,style: text_131732_14)),
                    SizedBox(width: 6.w),
                    Obx(() => Text(controller.selectUse.value.value ,style: text_131732_14)),
                    SizedBox(width: 3.w),
                    Image.asset('assets/images/ic_next.png',width: 15.w,height: 15.w)
                  ]),
                ),
              ),
              Container(margin: EdgeInsets.symmetric(horizontal: 20.w), height: 0.2,color: Color_line),
              Visibility(
                visible: controller.isAuditing.value,
                child: Container(
                  height: 40.w,
                  margin: EdgeInsets.symmetric(horizontal: 20.w),
                  child: InkWell(
                    onTap: () => {},
                    child: Row(children: [
                      Expanded(child: Text('年利率（年利率=日利率*365)' ,style: text_131732_14)),
                      SizedBox(width: 6.w),
                      Text('17%' ,style: text_131732_14),
                      SizedBox(width: 18.w),
                    ]),
                  ),
                ),
              ),
              Visibility(
                visible: controller.isAuditing.value,
                child: Container(margin: EdgeInsets.symmetric(horizontal: 20.w), height: 0.2,color: Color_line)),
              Container(
                height: 40.w,
                margin: EdgeInsets.symmetric(horizontal: 20.w),
                child: InkWell(
                  onTap: () => controller.toIdAuth(),
                  child: Row(children: [
                    Expanded(child: Text('身份认证' ,style: text_131732_14)),
                    SizedBox(width: 6.w),
                    Obx(() => Container(
                        decoration: BoxDecoration(
                            color: controller.isAuthID.value?const Color(0xffE9F7FE):Color_main,
                            borderRadius: BorderRadius.all(Radius.circular(8.w))
                        ),
                        child: Text(controller.isAuthID.value ? '  已认证  ':'  去认证  ' ,style: controller.isAuthID.value ?text_main_14:text_white_14))),
                    SizedBox(width: 3.w),
                    Image.asset('assets/images/ic_next.png',width: 15.w,height: 15.w)
                  ]),
                ),
              ),
              Container(margin: EdgeInsets.symmetric(horizontal: 20.w), height: 0.2,color: Color_line),
              Container(
                height: 40.w,
                margin: EdgeInsets.symmetric(horizontal: 20.w),
                child: InkWell(
                  onTap: () => controller.toBaseAuth(),
                  child: Row(children: [
                    Expanded(child: Text('基本信息' ,style: text_131732_14)),
                    SizedBox(width: 6.w),
                    Obx(() => Container(
                        decoration: BoxDecoration(
                            color: controller.isAuthBase.value?const Color(0xffE9F7FE):Color_main,
                            borderRadius: BorderRadius.all(Radius.circular(8.w))
                        ),
                        child: Text(controller.isAuthBase.value ? '  已认证  ':'  去认证  ' ,style: controller.isAuthBase.value ?text_main_14:text_white_14))),
                    SizedBox(width: 3.w),
                    Image.asset('assets/images/ic_next.png',width: 15.w,height: 15.w)
                  ]),
                ),
              ),
              Container(margin: EdgeInsets.symmetric(horizontal: 20.w), height: 0.2,color: Color_line),
            ])
        ),
        SizedBox(height: 35.w),
        InkWell(
          highlightColor: Colors.transparent, // 透明色
          splashColor: Colors.transparent, // 透明色
          onTap: () => controller.clickApply(),
          child: Container(
              margin: EdgeInsets.symmetric(horizontal: 20.w),
              height: 45.w,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(25.w),
                color: Color_main,
              ),
              child: Center(child: Text("马上领钱",style: text_white_16))),
        )
      ])),
    );
  }
}
